/**
 * Created by Administrator on 2016/12/16.
 */
/*解析href*/
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for (var i = 0; i < str.length; i++) {
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
console.log(json);

/*layer弹框效果*/
function ifrLayer (element , url){
    element.on("click", '', function() {
        layer.open({
            type: 2,
            maxmin: false,
            shadeClose: true,
            area : ['100%' , '100%'],
            content:url,
            title :　false
        });
    });
}
/*表格加载*/
var oUrl = `http://192.168.59.3:8082/console/material/equipmentTypeList?projectCode=${json.projectCode}&type=3`;

$('#workTable').bootstrapTable({
    method:"get",
    url:oUrl,
    onLoadSuccess : function (data) {
        console.log("设备加载成功。。。。");
        console.log(data);
        ifrLayer($('.href-click'),`../materiel-detail-e/materiel-detail-e.html?$projectCode=${json.projectCode}&equipmentType=${data.rows[0].equipmentType}`);
    }
});
/*回调函数*/
function responseHandler(res) {

    var needData = {
        rows: res.data,
       // total: res.data.total
    };
    return needData;
}

function indexFmt(val,row,index){
    return index+1;
}

function workTableQuery(params){

    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;

    return params;
}
function totalFmt(val,row,index){
    return row.adjustmentnumber+row.number;
}

/*添加class  active*/
var iIndex = 0,
    oLis = $('#tab-fifth li');
oLis.click(function (){
    iIndex = $(this).index();
    oLis.removeClass('active').eq(iIndex).addClass('active');

});

ifrLayer($('#ifr-worker'),`../Worker-attendance/Worker-attendance.html?projectCode=${json.projectCode}`);

ifrLayer($('#ifr-plat'),`../platform-consume/platform-consume.html?projectCode=${json.projectCode}`);


ifrLayer($('#mc1'),`../materiel-consume/materiel-consume.html?projectCode=${json.projectCode}`);
ifrLayer($('#mf3'),`../materiel-facility/materiel-facility.html?projectCode=${json.projectCode}`);

/*
function handlerFmt(value,row){
    //console.log(row);
    return `<button onclick="getDetail(json.projectCode,${row.equipmentType})"><span class="icon icon-caret-down"></span></button>`
}
function getDetail(code1,code2,code3,code4){
    //console.log(code1);
    //  console.log(code2);
    // console.log(code3);
    // console.log(code4);
    layer.open({
        type: 2,
        maxmin: false,
        shadeClose: false,
        closeBtn: 1,
        area : ['100%' , '100%'],
        content:`../materiel-detail-e/materiel-detail-e.html?projectCode=${code1}&equipmentType=${code2}`,
        title :　false
    });
}*/
